package com.example.administrator.timecount;

import android.Manifest;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends PermissionActivity {
    private String TAG="MainActivity";
    private PermisonListener permisonListener;
    private String[] Permisons = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        permisonListener = new PermisonListener();
        performRequestPermissions("拒绝权限后请到设置中手动开启权限", Permisons, 101, permisonListener);
    }

    private class PermisonListener implements PermissionsResultListener {
        @Override
        public void onPermissionGranted() {
            Log.e(TAG, "onPermissionGranted: ");
            startService(new Intent(MainActivity.this,TimeCountService.class));

        }

        @Override
        public void onPermissionDenied() {

        }
    }


}
